import store from '../store/index.js';
import util from '../utils/utils.js'



export const axios = ({ path, type, data }) => {
	return new Promise((resolve, reject) => {
		
		let headerObj = {
			'Content-Type': 'application/json;charset=UTF-8',
			'token':store.state.token
		}
		
		
		// let path = 'http://test2.gongsizhang.com/'+path;?S
		let url = '';
		// #ifdef MP-WEIXIN
			// url = 'http://test2.gongsizhang.com';
		// #endif
		uni.request({
			url: url+path,
			method: type,
			data,
			header: headerObj,
			success: (res) => {
				
				resolve(res.data)
			},
			fail : (res) => {
				uni.showToast({
					icon: 'none',
				    title: '网络异常',
				    duration: 2000
				})
			},
			complete: finsh => {
				
			}
		})
	})
}